﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Web;
using System.Xml;

namespace zielonka.co.uk.extensions.system.xml
{    
	//Description:	Append new child XmlElement to base XmlElement.
    /*
        XmlDocument doc = new XmlDocument();
        XmlElement root = doc.CreateElement("Root");
        doc.AppendChild(root);
        root.AppendNode("Child 1 Name", "Child 1 Value");
        root.AppendNode("Child 2 Name", 123);
     */
    public static partial class XMLElementExtensions
	{
        public static void AppendNode<T>(this XmlElement root, string name, T value)
        {
            XmlDocument doc = root.OwnerDocument;
            if (doc != null)
            {
                XmlElement code = doc.CreateElement(name);
                XmlText codeText = doc.CreateTextNode(value.ToString());
                root.AppendChild(code);
                code.AppendChild(codeText);
            }
        }
	}
}
